<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Token_model extends MY_model {
	public function __construct() {
		parent::__construct ( 'token' );
	}
	/**
	 * 创建数据表
	 */
	public function create() {
		$this->drop ();
		$sql = "CREATE TABLE `token` (
	  					`code` varchar(20) NOT NULL COMMENT '平台代码',
	  					`name` varchar(100) NOT NULL COMMENT '平台名称',
	  					`detail` text COMMENT '平台简介',
	 					`domain` varchar(100) NOT NULL COMMENT '域名',
	  					`pkey` varchar(40) DEFAULT NULL COMMENT '公钥',
	 					`skey` varchar(40) DEFAULT NULL COMMENT '私钥',
	  					`timestamp` int(10) unsigned DEFAULT '0' COMMENT '时间戳',
	 					`status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
	  					PRIMARY KEY (`code`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='令牌认证表';";
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
	/**
	 * 删除数据表
	 */
	public function drop() {
		$sql = 'DROP TABLE IF EXISTS `token`;';
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
}